<?php
class Hydrum_Application_Resource_Area extends Zend_Application_Resource_ResourceAbstract
{
    /**
     * Enter description here ...
     * @var unknown_type
     */
    protected $area;

    /**
     * Initialize Front Controller
     *
     * @return Zend_Controller_Front
     */
    public function init()
    {
        return $this->getArea();
    }

    protected function getArea()
    {
        if ($this->area == null) {
            $uri = $_SERVER['REQUEST_URI'];

            $options = $this->getOptions();

            foreach ($options as $option) {
                if (preg_match('/' . $option['uri'] . '/i', $uri)) {
                    $this->area = new Hydrum_Area($option);
                    break;
                }
            }
        }

        return $this->area;
    }
}
